package com.smallnico.opencv;

import java.util.ArrayList;
import java.util.List;

import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
import org.opencv.core.MatOfPoint;
import org.opencv.core.Point;
import org.opencv.core.Scalar;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;

public class Test2 {

	public static void main(String[] args) {
		System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

		String outPath = "C:\\Users\\ainil\\Desktop\\test_out.jpg";
		String originalImgPath1 = "C:\\Users\\ainil\\Desktop\\20180419152946919.png";
		String originalImgPath = "C:\\Users\\ainil\\Desktop\\test.jpg";

		Mat img = Imgcodecs.imread(originalImgPath);
		Mat imgHSV = img.clone();
		//RGB->HSV
		Imgproc.cvtColor(img, imgHSV, Imgproc.COLOR_BGR2GRAY);
		Scalar minValues = new Scalar(100, 200, 90);
		Scalar maxValues = new Scalar(151, 238, 107);
		Mat mask = new Mat();
		Core.inRange(imgHSV, minValues, maxValues, mask);

		
		Imgcodecs.imwrite(outPath, mask);
	}
}
